OpenAL currently has 8 different distance models for calculating the doppler effects of sounds, each of which, are described in the sub-sections below. Keep note of the following variables while reading the formulas in sections below:
BASE_VOLUME = the volume of a sound before ANY settings are applied to it (e.g. volume adjustments, strength, velocity, etc)
DISTANCE = the distance between the listener and the sound source in question.
MINIMUM_DISTANCE = the distance the listener has to be away from the sound before any rolloff is applied to it
MAXIMUM_DISTANCE = the distance from the listener that the sound may still be heard after rolloff is applied to it.
SOUND_STRENGTH = the strength of the sound, which will either be the default value of 1, or whatever it has been set to with AL SET SOUND STRENGTH.
None
When the distance model is set to None, OpenAL will not perform any doppler effect calculations on any sound sources. The base volume of all sounds will always be 1, regardless of the position, velocity and direction of sounds and the listener. This model may be useful if you wish to use your own method/formula for calculating the base volume of sounds.
BASE_VOLUME = 1.0
Inverse Distance
When the distance model is set to Inverse distance, the base volume of each 3D sound will be calculated as:
BASE_VOLUME = MINIMUM_DISTANCE / (MINIMUM_DISTANCE + (1.0 / SOUND_STRENGTH) * (DISTANCE – MINIMUM_DISTANCE))
Inverse Distance Clamped
When the distance model is set to Inverse distance clamped, the base volume of each 3D sound will be calculated as:
rem distance is clamped so it cannot go lower than the max distance or higher than the minimum distance (i.e. inversed).
DISTANCE = clamp(DISTANCE, MAXIMUM_DISTANCE, MINIMUM_DISTANCE)
BASE_VOLUME = MINIMUM_DISTANCE / (MINIMUM_DISTANCE + (1.0 / SOUND_STRENGTH) * (DISTANCE – MINIMUM_DISTANCE))
Linear Distance
When the distance model is set to Linear Distance, the base volume of each 3D sound will be calculated as:
rem Do not allow the distance to go below the maximum distance to avoid a negative base volume
DISTANCE = min(DISTANCE, MAXIMUM_DISTANCE)
BASE_VOLUME = (1.0 – (1.0 / SOUND_STRENGTH) * (DISTANCE – MINIMUM_DISTANCE) / (MAXIMUM_DISTANCE – MINIMUM_DISTANCE))
Linear Distance Clamped
When the distance model is set to Linear Distance Clamped, the base volume of each 3D sound will be calculated as:
rem clamp distance between min and max distance, so the volume has a limit as to how high it can go as the listener moves closer.
DISTANCE = clamp(DISTANCE, MAXIMUM_DISTANCE, MINIMUM_DISTANCE)
BASE_VOLUME = (1.0 – (1.0 / SOUND_STRENGTH) * (DISTANCE – MINIMUM_DISTANCE) / (MAXIMUM_DISTANCE – MINIMUM_DISTANCE))
Exponent Distance
When the distance model is set to Exponent Distance, the base volume of each 3D sound will be calculated as:
BASE_VOLUME = (DISTANCE / MINIMUM_DISTANCE) ^ (- AL_ROLLOFF_FACTOR)
Exponent Distance Clamped
When the distance model is set to Exponent Distance Clamped, the base volume of each 3D sound will be calculated as:
DISTANCE = clamp(DISTANCE, MAXIMUM_DISTANCE, MINIMUM_DISTANCE)
BASE_VOLUME = (DISTANCE / MINIMUM_DISTANCE) ^ (- AL_ROLLOFF_FACTOR)